<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of TheLoaiDAO
 *
 * @author HOANGPHUC
 */
class TheLoaiDAO {

    public function __construct() {
        require ("../UTIL/MySQLProvider.php");
    }

    public function Create($column, $value) {

        $dbHandle = new MySQLProvider();
        $flag = $dbHandle->Insert("theloai", $column, $value);
        $dbHandle->CloseConnection();
        return $flag;
    }

    public function Edit($column, $value, $whereColumn, $whereValue) {
        //require ("/UTIL/MySQLProvider.php");
        $dbHandle = new MySQLProvider();
        $flag = $dbHandle->Update("theloai", $column, $value, "ID", $whereValue);
        $dbHandle->CloseConnection();
        return $flag;
    }

    public function Remove($whereColumn, $whereValue) {
        // require ("/UTIL/MySQLProvider.php");
        $dbHandle = new MySQLProvider();
        $flag = $dbHandle->Delete("theloai", "ID", $whereValue);
        $dbHandle->CloseConnection();
        return $flag;
    }

    public function findAll() {
        // require ("/UTIL/MySQLProvider.php");
        require ("/ENTITY/TheLoai.php");
        $dbHandle = new MySQLProvider();
        $result = $dbHandle->GetResultSet("select * from TheLoai");
        $arr = array();
        $i = 0;

        while ($r = mysql_fetch_array($result)) {
            
            $theLoai = new TheLoai();
            $theLoai->SetId($r['ID']);
            $theLoai->SetTen($r['TEN']);
            $theLoai->SetMoTa($r['MOTA']);
            $theLoai->SetTenEn($r['TEN_EN']);
            $theLoai->SetMoTaEn($r['MOTA_EN']);
            $arr[$i] = $theLoai;
            $i++;
        }
        $dbHandle->CloseConnection();
        return $arr;
    }

}

?>
